package com.gitee.feizns.quickstart.ding.talk.api.top.api.role;

import com.dingtalk.api.DefaultDingTalkClient;
import com.dingtalk.api.DingTalkClient;
import com.dingtalk.api.request.OapiRoleListRequest;
import com.dingtalk.api.response.OapiRoleListResponse;
import com.gitee.feizns.quickstart.ding.talk.utils.Utils;
import lombok.SneakyThrows;

/**
 * 获取角色列表（/topapi/role/list）
 * 接口路径：<a href="https://open.dingtalk.com/document/orgapp/obtains-a-list-of-enterprise-roles">获取角色列表（/topapi/role/list）</a>
 * @link <a href="https://open.dingtalk.com/document/orgapp/obtains-a-list-of-enterprise-roles">服务端API > 通讯录管理 > 角色管理 > 获取角色列表</a>
 * @author feizns
 * @since 2024/7/28
 */
public class RoleList {

    /**
     * 执行
     * @param accessToken 访问令牌
     * @param req 要求
     * @return {@link Long }
     */
    @SneakyThrows
    public static OapiRoleListResponse.PageVo execute(String accessToken, OapiRoleListRequest req) {
        DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/role/list");
        OapiRoleListResponse rsp = client.execute(req, accessToken);
        return Utils.ifErrorThrow(rsp).getResult();
    }

}
